package homework;

import lesson.Util;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Atm  extends JFrame  {
    private Image bgimg = Util.getImage("/background.jpg");
    private Login login = new Login(this);
    private Menu menu = new Menu(this);
    private Save save = new Save(this);
    private Find find = new Find(this);
    private Get get = new Get(this);
    private CardLayout cardLayout = new CardLayout();


    public Atm(){
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgimg, 0, 0, 1100, 650, this);
            }
        });
//#################################添加组件######################################
        this.setLayout( cardLayout);
        this.add("login",login);
        this.add("menu",menu);
        this.add("save",save);
        this.add("get",get);
        this.add("find",find);



        this.setSize(1100, 650);//设置大小
        this.setTitle("测试窗口");//设置标题
        this.setLocationRelativeTo(null);//设置窗口居中
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);//设置窗口关闭时程序结
        this.setVisible(true);//设置窗体可见
    }

    public void switchPanel(String name){
        cardLayout.show(this.getContentPane(),name);
    }

    public static void main(String[] args) {
        new Atm();
    }
}
